<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header("Location: ../login.php");
    exit();
}

require '../config.php';

$comment_id = $_GET['id'];

// 删除评论
$stmt = $conn->prepare("DELETE FROM comments WHERE id = ?");
$stmt->bind_param("i", $comment_id);

if ($stmt->execute()) {
    header("Location: manage_comments.php");
    exit();
} else {
    echo "<p class='error'>删除评论失败，请重试</p>";
}

$stmt->close();
$conn->close();
?>